package com.fangsiqi.mashibing;

public class Volatile {
	private static boolean flag=true;
	// private static volatile boolean flag=true;

	private static TimeCalculator calculator=new TimeCalculator();

	public static void main(String[] args) throws InterruptedException {
		calculator.start();
		Thread t1=new Thread(()->{
			while (flag){
				System.out.println("1");
			}
			System.out.println("t1线程结束了");
		});

		t1.start();
		System.out.println("main线程将flag改为了false");
		Thread.sleep(10000);
		flag=false;
		calculator.end();
		System.out.println(calculator.calculateDuration());
		// System.out.println("main线程将flag改为了false");
	}
}
